package com.yc.mybatis.mapper;

import com.yc.mybatis.bean.SpHall;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.mapping.FetchType;

import java.util.List;
import java.util.Map;

public interface HallDao {

    @Select("select * from sp_hall where seats between #{min} and #{max}")
    @Results( id = "rm2",
    value = {
            // 主键映射
//            select = "com.yc.mybatis.mapper.PlanMapper.selectPlanByhid", fetchType = FetchType.LAZY
            @Result( column = "id", property = "id", id = true),
            @Result( column = "id", property = "plans",
                    many = @Many(select = "com.yc.mybatis.mapper.PlanMapper.selectPlanByhid", fetchType = FetchType.LAZY))
    })
    List<SpHall> selectBySeats(
            @Param("min") int min,
            @Param("max") int max);

    List<SpHall> selectByObj(SpHall spHall);

    SpHall selectById(int id);

    void update(SpHall spHall);

    void update1(SpHall spHall);

    List<SpHall> selectByFlag(
            @Param("name") String name,
            @Param("flag") int flag);

    List<SpHall> selectInIds( @Param("idList") List<Integer> idList);

    void insert (SpHall spHall);

    List<SpHall> selectOrderBy(@Param("orderName") String order);

    List<Map<String,Object>> selectSQL(@Param("sql") String sql);
}
